/**
 * ...
 * @author Franco Ponticelli
 */

package uform.ui.comp;

import uform.property.IProperty;
import uform.property.Property;

class NamedComponent extends Component, implements INamedComponent
{
	public var name(default, setName) : String;
	private function new(name : String)
	{
		super();
		this.name = name;
	}
	
	override function _id()
	{
		if (null == name || "" == name) 
			return super._id()
		else
			return name;
	}
	
	override public function path()
	{
		var parts = [];
		var p = parent.isNull() ? "" : parent.get().path();
		if (p != "")
		{
			if(StringTools.endsWith(p, "."))
				p = p.substr(0, -1);
			parts.push(p);
		}
		if (null != name && "" != name)
			parts.push(name);
		return parts.join(".");
	}
	
	function setName(name : String)
	{
		return this.name = name;
	}
}